﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Somnus.Core.SceneManager;
using Somnus.Objects;
using Somnus.Core;
using System;


namespace Somnus.Scenes
{
    class Menu : SceneBase
    {
        Objeto2D fundo;
        Objeto2D brilhoFundo;

        public override void start()
        {
            fundo = new Objeto2D(Game1.getInstance().Content.Load<Texture2D>("Menu/splash_2"), null, 0.5f);
            brilhoFundo = new Objeto2D(Game1.getInstance().Content.Load<Texture2D>("Menu/splash_2_brilho_4"), null, 0.5f);
            fundo.x = brilhoFundo.x = Game1.getInstance().Window.ClientBounds.Width / 2;
            fundo.y = brilhoFundo.y = Game1.getInstance().Window.ClientBounds.Height / 2;

            SoundManager.AddMusic("rascunho", Game1.getInstance().Content.Load<Song>("Musica/Rascunho"));
            SoundManager.SetMusic("rascunho", true);
            MediaPlayer.IsVisualizationEnabled = true;
        }

        public override void update(GameTime gameTime)
        {
            SoundManager.Update();
            brilhoFundo.alpha = SoundManager.MusicActivityBySample(0.8f);
            brilhoFundo.ScaleX = brilhoFundo.ScaleY = 1 + SoundManager.MusicActivityBySample(0.8f) * 0.5f;

            if (Controller.KeyPressed(Keys.Space))
            {
                SceneManager.setScene(new Level1(), true);
            }
           
        }

        public override void  draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
 	        fundo.draw(gameTime, spriteBatch);
            brilhoFundo.draw(gameTime, spriteBatch);
            spriteBatch.End();
        }

        public override void terminate()
        {
            SoundManager.StopMusic();
        }
    }


}
